<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../js/vue.js"></script>

</head>
<body>
    <!-- 准备好一个容器 -->
    <div id="root">
        <app></app>
    </div>

</body>
    <script type="text/javascript">

        //定义student组件
        const student = {
            template:`
                <div>
                    <h2>学生姓名：{{studentName}}</h2>    
                    <h2>学生年龄：{{age}}</h2>    
                </div>
            `,
            data(){
                return {
                    studentName:'张三',
                    age:18
                }
            }
        }

        //定义组件：简写
        const school = {
            template:`
                <div>
                    <h2>学校名称：{{schoolName}}</h2>
                    <h2>学校地址：{{address}}</h2>
                    <student></student>
                </div>
            `,
            data(){
                return {
                    schoolName:'尚硅谷',
                    address:'北京'
                }
            },
            components:{
                student
            }
        }
 
        const hello = {
            template:`<h1>{{msg}}</h1>`,
            data(){
                return {
                    msg:'hello Vue'
                }
            }
        }

         //定义一个app组件，管理所有组件
         const app = {
            template:`
                <div>
                    <school></school>
                    <hello></hello>    
                </div>
            `,
            components:{
                school,
                hello
            }
        }

        new Vue({
            el:'#root',
            data:{
                
            },

            components:{
                app
            }
        })        

    </script>

</html>